#!/system/bin/sh
case $1 in
    ppp1)
	/android/bin/iptables --flush;
	/android/bin/iptables --table nat --flush;
	/android/bin/iptables --delete-chain;
	/android/bin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE;
	/android/bin/iptables --append FORWARD --in-interface ppp1 -j ACCEPT;
	echo 0 > /proc/sys/net/ipv4/ip_forward;
	echo 1 > /proc/sys/net/ipv4/ip_forward;
	echo $PPPD_PID > /etc/ppp/ppp1.pid;
	;;
    ppp0)
        /system/bin/setprop "net.interfaces.defaultroute" "gprs";
        echo $PPPD_PID > /etc/ppp/ppp0.pid;
        ;;
esac

# Use interface name if linkname is not available
NAME=${LINKNAME:-"$1"}

/system/bin/setprop "net.$NAME.dns1" "$DNS1"
/system/bin/setprop "net.$NAME.dns2" "$DNS2" 
/system/bin/setprop "net.$NAME.local-ip" "$IPLOCAL" 
/system/bin/setprop "net.$NAME.remote-ip" "$IPREMOTE" 

